package com.spring;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.TestString;

@Controller
@EnableAutoConfiguration
@Configuration
public class TestSpring {
	
	@Autowired
	private RedisConnectionFactory redisFactory;
	
	@RequestMapping("/")
	@ResponseBody
	Object home() {
		RedisTemplate<String, String> template = new RedisTemplate<>();
		template.setConnectionFactory(redisFactory);
		JdkSerializationRedisSerializer serializer = new JdkSerializationRedisSerializer();
		template.setKeySerializer(new StringRedisSerializer());
		template.setValueSerializer(serializer);
		template.afterPropertiesSet();
		ListOperations<String, String> ops = template.opsForList();
		Long leftPushAll = ops.leftPushAll("v3", "xx","aa","bb","xwsw");
		List<String> range = ops.range("v3", 0, 10);
		return range;
	}

	public static void main(String[] args) throws Exception {
		
		SpringApplication.run(TestString.class, args);
	}
}
